#include "LogProcessThread.h"
#include "common.h"
#include "SyncQueue.h"


#define    DEFAULT_LOG_PATH    "/usr/local/ConferenceManagerService/app/logs"

CLogProcessThread::CLogProcessThread()
{
    memset(m_LogPath, 0x00, sizeof(m_LogPath));
}

CLogProcessThread::~CLogProcessThread()
{
    //dtor
}

void CLogProcessThread::SetPath(const char* log_path)
{
    if (log_path)
    {
        memcpy(m_LogPath, log_path, strlen(log_path) + 1);
    }
    else
    {
        memcpy(m_LogPath, DEFAULT_LOG_PATH, strlen(DEFAULT_LOG_PATH) + 1);
    }
}


void CLogProcessThread::Process(void)
{
    std::string log;

    while (m_bRun || !g_LogQueue.Empty())
    {
        log.assign("");

        if(g_LogQueue.RemoveHead(log, 1)) //1s
        {
            CLogHelper::GetInstance(m_LogPath)->Log(log.c_str());
        }
    }
}
